package com.atguigu.edu2021.mock.log;


import com.atguigu.edu2021.mock.log.enums.DisplayType;
import com.atguigu.edu2021.mock.log.enums.ItemType;
import com.atguigu.gmall2020.mock.util.RandomBox;
import com.atguigu.gmall2020.mock.util.RandomNum;
import lombok.AllArgsConstructor;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

import static com.atguigu.edu2021.mock.config.AppConfig.*;


@Data
@AllArgsConstructor
public class AppDisplay {

    ItemType item_type;

    String item;

    DisplayType display_type;

    Integer order;

    Integer pos_id;

    //
    public static List<AppDisplay> buildList( ) {
        List<AppDisplay> displayList = new ArrayList();


        int displayCount = RandomNum.getRandInt(min_display_count, max_display_count);
        int activityCount = displayList.size();// 商品显示从 活动后面开始
        for (int i = 1 + activityCount; i <= displayCount + activityCount; i++) {
            int skuId = RandomNum.getRandInt(1, max_course_id);
            int pos_id = RandomNum.getRandInt(1, max_pos_id);
            RandomBox<DisplayType> dispTypeGroup = RandomBox.<DisplayType>builder().add(DisplayType.promotion, 30)
                    .add(DisplayType.query, 60).add(DisplayType.recommend, 10).build();
            DisplayType displayType = dispTypeGroup.getValue();

            AppDisplay appDisplay = new AppDisplay(ItemType.course_id, skuId + "", displayType, i, pos_id);
            displayList.add(appDisplay);
        }


        return displayList;
    }


}

